<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      box-sizing: border-box;
    }
    body {
      display: flex;
      justify-content: center;
      align-items: center;
      background-color: #686de0;
      height: 100vh;
      overflow: hidden;
      margin: 0;
      padding: 20px;
    }
    .container {
      background-color: #fff;
      border-radius: 10px;
      width: 800px;
      max-width: 100%;
      text-align: center;
      padding: 50px 20px;
    }
    .h3 {
      margin: 0;
      opacity: 0.5;
      letter-spacing: 1px;
    }
    .joker {
      font-size: 30px;
      letter-spacing: 1px;
      line-height: 40px;
      margin: 50px auto;
      max-width: 600px;
    }
    .btn {
      cursor: pointer;
      background-color: #9f68e0;
      color: #fff;
      border-radius: 10px;
      border: 0;
      box-shadow: 0 5 rgba(0, 0, 0, 0.1);
      font-size: 16px;
      padding: 14px 40px;
    }
    .btn:active {
      transform: scale(0.98);
    }
  </style>
</head>
<body>
  <div class="container">
    <h3>Don't Laugh Challenge</h3>
    <div id="joker" class="joker">笑话真好笑</div>
    <button id="jokerBtn" class="btn">点我有笑话</button>
  </div>

  <script>
    const joker = document.getElementById("joker");
    const jokerBtn = document.getElementById("jokerBtn");

    jokerBtn.addEventListener("click", getjoker);
    getjoker();

    async function getjoker() {
      const config = {
        headers: {
          Accept: "application/json",
        }
      };

      const res = await fetch("https://icanhazdadjoke.com", config);
      const data = await res.json();
      console.log(data);
      joker.innerHTML = data.joke;
    };
  </script>
</body>
</html>